#version 460
#extension GL_GOOGLE_include_directive : enable
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require

#include "../../../../core/shader_std.h"
#include "../../../../core/shader_built_in_functions.h"
#include "../../../../core/shader_color.h"
#include "../../../../core/shader_curve.h"

layout(location = 0) in vec2 inPoint;
layout(location = 1) in vec2 inUV_Width;
layout(location = 2) in uvec2 inColor_Type;



layout(push_constant, scalar) uniform DRAWPROP_push_constants {
	S_ConstPush_Waveform const_push;
};

layout(std140, binding = 1, scalar) readonly buffer U_Matrix1 {
	mat3 tranform[];
};

layout(std140, binding = 2, scalar) readonly buffer U_Matrix2 {
	S_Waveform waveform[];
};



layout(location = 1) out VS_GS_VERTEX {
	vec4 vColor;
	vec2 vPosA;
	vec2 vPosB;
}vertex_in;



void main(void){
	mat3 mat = tranform[const_push.m_Offset_Instance + gl_InstanceIndex];

	S_Waveform wf = waveform[const_push.m_Offset_Waveform + gl_DrawID];
	
	float heigth = wf.m_SampleHigth * 0.5;
	vertex_in.vPosA = (mat * vec3(vec2(inUV_Width.x * wf.m_SampleWidth, inPoint.x * heigth) + wf.m_SampleOffset, 0.0)).xy;
	vertex_in.vPosB = (mat * vec3(vec2(inUV_Width.y * wf.m_SampleWidth, inPoint.y * heigth) + wf.m_SampleOffset, 0.0)).xy;
	//vertex_in.vPosA = (mat * vec3(vec2(inUV_Width.x, inPoint.x * heigth) + wf.m_SampleOffset, 0.0)).xy;
	//vertex_in.vPosB = (mat * vec3(vec2(inUV_Width.y, inPoint.y * heigth) + wf.m_SampleOffset, 0.0)).xy;

	vertex_in.vPosA.y += heigth;
	vertex_in.vPosB.y += heigth;
	vertex_in.vColor = f_glsl_buildColor(wf.m_Color);
}



